namespace IFramework
{
    public class Log 
    {
        public static int LogLevel = 0;
        private static ILoger loger;
        public static void SetLoger(ILoger loger)
        {
            Log.loger = loger;
        }
        private static void CheckNull()
        {
            if (loger==null)
            {
                SetLoger(new DefaultLoger());
            }
        }
        public static void L(object message,int lev=0, string format = null, params object[] paras)
        {
            if (LogLevel > lev) return;
            CheckNull();
            if (format == null)
            {
                loger.Log(LogType.Default, message, paras);
            }
            else
            {
                loger.LogFormat(LogType.Default,format, message, paras);
            }

        }
        public static void W(object message, int lev = 0, string format = null, params object[] paras)
        {
            if (LogLevel > lev) return;
            CheckNull();
            if (format == null)
            {
                loger.Log(LogType.Warning, message, paras);
            }
            else
            {
                loger.LogFormat(LogType.Warning, format, message, paras);
            }

        }
        public static void E(object message, int lev = 0, string format = null, params object[] paras)
        {
            if (LogLevel > lev) return;
            CheckNull();
            if (format == null)
            {
                loger.Log(LogType.Error, message, paras);
            }
            else
            {
                loger.LogFormat(LogType.Error, format, message, paras);
            }
        }
    }
}